package com.SmartCare.controller.common;

import com.SmartCare.common.Result;
import com.SmartCare.service.MailService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "邮箱服务接口")
@Slf4j
public class MailController {
    @Autowired
    private MailService mailService;

    //获取验证码
    @GetMapping("/getAuthCode")
    public Result getAuthCode(String mail) {
        return mailService.getAuthCode(mail);
    }

    //后台获取注册验证码
    @GetMapping("/manager/sign-code")
    public Result sendSignCode(@RequestParam String mail) {
        return mailService.managerSendCode(mail, "SIGN");
    }

    //后台验证注册验证码
    @GetMapping("/manager/verify-sign")
    public Result verifyManagerSign(@RequestParam String mail, @RequestParam String code) {
        return mailService.managerVerifyCode(mail, code, "SIGN");
    }

    //后台获取登录验证码
    @GetMapping("/manager/login-code")
    public Result sendLoginCode(@RequestParam String mail) {
        return mailService.managerSendCode(mail, "LOGIN");
    }

    //后台验证登录验证码
    @GetMapping("/manager/verify-login")
    public Result verifyManagerLogin(@RequestParam String mail, @RequestParam String code) {
        return mailService.managerVerifyCode(mail, code, "LOGIN");
    }

    //后台获取修改密码验证码
    @GetMapping("/manager/change-code")
    public Result sendChangeCode(@RequestParam String mail) {
        return mailService.managerSendCode(mail, "CHANGE");
    }


    //后台验证修改密码验证码
    @GetMapping("/manager/verify-change")
    public Result verifyManagerChange(@RequestParam String mail, @RequestParam String code) {
        return mailService.managerVerifyCode(mail, code, "CHANGE");
    }
}
